<?php
namespace app\api\controller;

use think\facade\Cache;
use think\facade\Db;

class Index extends Api
{
    public function phpInfo()
    {
        phpinfo();
    }
    public function index()
    {
        $uid = rand(1,99);
        $page = rand(1,10);
//        $page = (int)request()->param('page',1);
        $limit = $this->page($page);
        $sql = "select count(*) as count,max(score) as max,min(score) as min,round(avg(score)) as avg from tbl_learn_report where uid = $uid group by word_id order by create_time $limit";
        $res = Db::query($sql);
        if($res){
            $this->ajaxMessage(2000,'ok',$res);
        }else{
            $this->ajaxMessage(2001,'null');
        }
    }
    public function set()
    {
        $r_key = 'bb';
        $str = [1,2,3,4];
        Cache::store('redis')->set($r_key,$str,300);
    }
    public function get()
    {
        $r_key = 'bb';
        $res = Cache::store('redis')->get($r_key);
        var_dump($res);
    }
}
